import * as maintenantService from '../../services/alarm/maintenant';

export default {
  namespace: 'maintenant',
  state: {
    list : [],
    currentItem : {},
    current : 1,
    currentSize : 10,
    total : 0, 
    modalVisible : false,
    modalType : 'handle',
    newKey : '',
    timeType:'1',
  },
  reducers: {   
    qryListByParamsSuc(state, { payload }) {
      return { ...state, ...payload };
    },
 
  },
  effects: {  
    *qryListByParams({ payload },{ call, put }) {
      const { body } = yield call(maintenantService.qryListByParams,payload);
      yield put({ type: 'qryListByParamsSuc', payload: { list:body.data, current:body.current, currentSize:body.size, total:body.iTotalRecords }});
    },
 
   
  },
  subscriptions: {
    setup({ dispatch, history }) {
      return history.listen(({ pathname }) => {
        if (pathname === '/maintenant') {
          dispatch({ type: 'qryListByParams', payload:{timeType:'1'}});
        }
      });
    },
  },
};
